#include <ctime>
#include <cstdio>
#include <iostream>
#include "Comm.hpp"

void t()
{
    std::cout<<sizeof(fd_set)*8<<std::endl;
    std::cout<<"--------------------"<<std::endl;
}

int main()
{
    t();

    SetNonBlock(0);
    char buffer[1024];
    while(1)
    {
        sleep(1);
        ssize_t n = ::read(0, buffer, sizeof(buffer)-1);
        if(n>0)
        {
            buffer[n]=0;
            std::cout<<"Enter# "<<buffer;
            continue;
        }
        else if(n == 0)
        {
            std::cout<<"read done"<<std::endl;
            break;
        }
        else
        {
            if(errno == EWOULDBLOCK)
            {
                std::cout<<"read null, do other things"<<std::endl;
                continue;
            }
            std::cout<<"read error"<<std::endl;
            break;
        }
    }
    return 0;
}